home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 09 / 3 / DISK0932.ZIP / SOURCE.EXE / arc / GETREAL.PAS < prev    next >
Pascal/Delphi Source File  |  1987-09-08  |  1KB  |  54 lines

  1.  
  2.  PROGRAM getreal;       {Or, how do you bullet-proof numerical entries?}
  3.                         {One choice is don't, then get I/O crashes.....}
  4.                         {Contributed by: Count Zero Interrupt   &      }
  5.                         { 6/87           General Max von Birdface (Ret)}
  6.  
  7.     VAR
  8.        number : REAL;
  9.        code : INTEGER;
  10.  
  11.     PROCEDURE getreal1 (VAR number:REAL; VAR code:INTEGER);   
  12.  
  13.      { Looks at entry and assigns codes for appropriate & other types }
  14.  
  15.        VAR
  16.           entry : STRING[30];
  17.  
  18.        BEGIN
  19.          Read(entry);
  20.          Val(entry,number,code);
  21.          CASE Length(entry) OF
  22.             0 : code := -2;
  23.             1 :
  24.               IF code > 0 THEN
  25.                     BEGIN
  26.                        code  := -1;
  27.                     END
  28.         END;
  29.       END;
  30.  
  31.                                    { Mainline for Procedure }
  32.  
  33.     BEGIN
  34.        ClrScr;
  35.        GotoXY(1,23);
  36.        Write('Enter a number: ');
  37.  
  38.         REPEAT
  39.            getreal1(number,code);
  40.              IF (code <> 0) THEN
  41.                 BEGIN
  42.                    Sound(100);
  43.                    Delay(500);
  44.                    NoSound;
  45.                    GotoXY(1,23);
  46.                    ClrEol;
  47.                    GotoXY(20,23);
  48.                    Write('Please!! Just Enter NUMBERS!! : ');
  49.                END
  50.         UNTIL (code = 0);
  51.         GotoXY(1,15);
  52.         Write('The number is: ',number:4:1);
  53.     END.
  54.